]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/doNotDisturb: Add new quick toggle
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 10 Apr 2025 18:09:35 +0000 (20:09 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 27 Jun 2025 11:36:17 +0000 (11:36 +0000)
It is a simple on/off control, which makes it a good fit for
quick settings. It also makes sense to expose the feature together
with other system controls, and while this somewhat removes the
control from the context of notifications, that doesn't seem to
be an issue on other platforms.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8339
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3691>

js/js-resources.gresource.xml
js/ui/panel.js
js/ui/status/doNotDisturb.js [new file with mode: 0644]
po/POTFILES.in

index df23e5eb7f65f9528316c2ffd1e772f583df931d..c116810a73eabee62e0788d30b86ea6fc151cfa4 100644 (file)
     <file>ui/status/brightness.js</file>
     <file>ui/status/camera.js</file>
     <file>ui/status/darkMode.js</file>
+    <file>ui/status/doNotDisturb.js</file>
     <file>ui/status/dwellClick.js</file>
     <file>ui/status/keyboard.js</file>
     <file>ui/status/location.js</file>
index b8d05634c33ca274f2b4c7c52e8fc063f033a8a1..d89b12c6bee2d21c386292b0f4e44ee07aba7227 100644 (file)
@@ -29,6 +29,7 @@ import * as SystemStatus from './status/system.js';
 import * as LocationStatus from './status/location.js';
 import * as NightLightStatus from './status/nightLight.js';
 import * as DarkModeStatus from './status/darkMode.js';
+import * as DoNotDisturb from './status/doNotDisturb.js';
 import * as BacklightStatus from './status/backlight.js';
 import * as ThunderboltStatus from './status/thunderbolt.js';
 import * as AutoRotateStatus from './status/autoRotate.js';
@@ -543,6 +544,7 @@ class QuickSettings extends PanelMenu.Button {
         this._thunderbolt = new ThunderboltStatus.Indicator();
         this._nightLight = new NightLightStatus.Indicator();
         this._darkMode = new DarkModeStatus.Indicator();
+        this._doNotDisturb = new DoNotDisturb.Indicator();
         this._backlight = new BacklightStatus.Indicator();
         this._powerProfiles = new PowerProfileStatus.Indicator();
         this._rfkill = new RFKillStatus.Indicator();
@@ -564,6 +566,7 @@ class QuickSettings extends PanelMenu.Button {
         if (this._network)
             this._indicators.add_child(this._network);
         this._indicators.add_child(this._darkMode);
+        this._indicators.add_child(this._doNotDisturb);
         this._indicators.add_child(this._backlight);
         this._indicators.add_child(this._powerProfiles);
         if (this._bluetooth)
@@ -596,6 +599,7 @@ class QuickSettings extends PanelMenu.Button {
         this._addItemsBefore(this._powerProfiles.quickSettingsItems, sibling);
         this._addItemsBefore(this._nightLight.quickSettingsItems, sibling);
         this._addItemsBefore(this._darkMode.quickSettingsItems, sibling);
+        this._addItemsBefore(this._doNotDisturb.quickSettingsItems, sibling);
         this._addItemsBefore(this._backlight.quickSettingsItems, sibling);
         this._addItemsBefore(this._rfkill.quickSettingsItems, sibling);
         this._addItemsBefore(this._autoRotate.quickSettingsItems, sibling);
diff --git a/js/ui/status/doNotDisturb.js b/js/ui/status/doNotDisturb.js
new file mode 100644 (file)
index 0000000..fe313d2
--- /dev/null
@@ -0,0 +1,39 @@
+import Gio from 'gi://Gio';
+import GObject from 'gi://GObject';
+
+import {QuickToggle, SystemIndicator} from '../quickSettings.js';
+
+const DoNotDisturbToggle = GObject.registerClass(
+class DoNotDisturbToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Do Not Disturb'),
+            iconName: 'notifications-disabled-symbolic',
+            toggleMode: true,
+        });
+
+        this._settings = new Gio.Settings({
+            schema_id: 'org.gnome.desktop.notifications',
+        });
+        this._settings.bind('show-banners',
+            this, 'checked',
+            Gio.SettingsBindFlags.INVERT_BOOLEAN);
+    }
+});
+
+export const Indicator = GObject.registerClass(
+class Indicator extends SystemIndicator {
+    constructor() {
+        super();
+        this._indicator = this._addIndicator();
+        this._indicator.icon_name = 'notifications-disabled-symbolic';
+
+        const toggle = new DoNotDisturbToggle();
+        toggle.bind_property('checked',
+            this._indicator, 'visible',
+            GObject.BindingFlags.SYNC_CREATE);
+
+        this.quickSettingsItems.push(toggle);
+    }
+});
+
index 9acd2f1d200d36363a0711f6cb7e91793f9d7ad8..1798b876f412a37849f8ffb962e65ff2153549fb 100644 (file)
@@ -68,6 +68,7 @@ js/ui/status/backlight.js
 js/ui/status/bluetooth.js
 js/ui/status/brightness.js
 js/ui/status/darkMode.js
+js/ui/status/doNotDisturb.js
 js/ui/status/dwellClick.js
 js/ui/status/keyboard.js
 js/ui/status/location.js